package sample;

import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.ProgressIndicator;

import java.net.URL;
import java.util.ResourceBundle;

/**
 * @author ml
 * @create 2017-11-17--15:35
 */
public class UploadController implements Initializable {
    @FXML ProgressBar progressbar;
    @FXML ProgressIndicator progressindictor;
    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }

    public void start(UpDialog upDialog){
        ObservableList<Person> pList=upDialog.getPList();
        System.out.println(pList.size());
        new Thread(createWorker()).start();

    }
    public Task createWorker() {
        return new Task() {
            @Override
            protected Object call() throws Exception {
                for (int i = 1; i < 10; i++) {
                    System.out.println(i/10.0);
                    progressbar.setProgress(i/9.0);
                    progressindictor.setProgress(i/9.0);
                    Thread.sleep(1000);
                }
                return true;
            }
        };
    }
}
